package com.vitabuybuy.tv.ui.home.adapter

import androidx.recyclerview.widget.RecyclerView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemGoodsBinding
import com.vitabuybuy.tv.dto.GoodsDto
import com.vitabuybuy.tv.inter.OnGoodItemClickListener
import com.library.common.base.BindRecycAdapter

class GoodsAdapter : BindRecycAdapter<ItemGoodsBinding, GoodsDto>(){
    override fun onBindViewHolder(
        mBinding: ItemGoodsBinding,
        itemData: GoodsDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.itemBean = itemData
        mBinding.position = position
        val itemOnClickListener = object : OnGoodItemClickListener {
            override fun onItemClick(item: GoodsDto, position: Int) {
                listener!!.invoke(mBinding ,itemData, position)
            }
        }
        mBinding.listenner = itemOnClickListener
    }

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_goods
    }
}
